use ar emoji on games and 3d apps objective learn how to use ar emoji as character of games or 3d applications using galaxy ar emoji sdk for unity partnership request to use the galaxy ar emoji sdk for unity, you must become an official samsung partner once done, you can fully utilize this code lab you can learn more about the partnership process by visiting galaxy ar emoji sdk page, here in samsung developers overview galaxy ar emoji sdk for unity with your samsung galaxy device, you can use the ar emoji feature to create an animated 3d avatar from your selfie photo or from a selection of a few suggested characters the avatar can display a range of emotions and body movements the galaxy ar emoji sdk for unity enables you to use this said ar emoji avatar in your application, such as using it to represent a game character tutorial process in this code lab, you will get to know about unity packages that can help you to use ar emoji avatars as character models in your unity application like games with simple code updates you will first learn about the basic pipeline for creation of app with ar emoji character with ar emoji sdk by loading a character model and rendering on the mobile app afterwards, you will learn a way of applying custom animation to the ar emoji character you can make your own app with a simple sequence of operation and by following the steps in this code lab moreover, you can learn about the character file import process and get to know more how you can maximize galaxy ar emoji sdk set up your environment you will need the following unity for windows lts release 2020 3 xf1 or latest compatible version editor for editing unity script like visual studio select different values to test how your game will look on monitors with different aspect ratios this is set to free aspect by default recommended 1024x2048 samsung galaxy device supporting ar emoji create your own ar emoji first, create your own ar emoji with the following steps run camera application click more > ar zone > ar emoji camera and the + button take your selfie and choose your gender edit your ar emoji a customize the looks, clothes, or accessories of your ar emoji b press next, once done check your avatar in both mask mode and in ar emoji studio create a unity project and configure the settings run unity and create an empty 3d sample project go to build settings a file > build settings b platform > android c click switch platform specific package name and keystore are necessary for testing in the next steps, it is explained in detail go to edit > player settings > player > other settings > identification > override default package name and enable it set the package name to samsung com fileprovidersample go to edit > project setting > player > publishing settings a enable custom keystore b add keystore file fileprovidersample jks with browser included in docs folder of gettingaremojiv3 3 unitypackage c enter the keystore password 123456 d set the project key setting alias keyalias password 123456 import packages run gettingaremojiv3 3 unitypackage, then click import check the imported sample app a go to assets > scenes > gettingaremojisample scene b click canvas import the next package, gltfimporterv3 3 unitypackage integrate the gltf importer to the sample app go to the sample scene a click assets > scenes > gettingemojisample unity b click canvas copy gltfcomponent prefab into your app to use gltf component property a click assets > prefabs b drag gltfcomponent prefab to your scene build and run go to file > build settings > build and run launch the sample app in your device a click getavatarlist button and check the ar emoji list stored on the device b select one of them c click getavatarthumbnailuri button d confirm if the ar emoji thumbnail is showing e click getavatarzipuri button f check if it shows the ar emoji avatar learn the basics of animation in unity animation system overview unity has a rich and sophisticated animation system sometimes referred to as mecanim while mecanim is recommended for use in most situations, unity has retained its legacy animation system, which existed before unity 4 when working with an older content created before unity 4, you may need to use the legacy animation system animator controller to apply the animation to the model, you must have a basic knowledge of the animation controller developers can easily control the animation with it an animator controller allows you to arrange and maintain a set of animation clips and associated animation transitions for a character or object in most cases it is normal to have multiple animations and switch between them when certain game conditions occur for example, you could switch from a walk animation clip to a jump animation clip whenever the space bar is pressed however, even if you only have a single animation clip, you still need to place it into an animator controller to use it on a gameobject the animator controller has references to the animation clips used within it, and manages the various animation clips and the transitions between them using a state machine, which could be thought of as a flow-chart of animation clips and transitions, or a simple program written in a visual programming language within unity here, the model is a loaded runtime, and then an animation controller component is added to the model therefore, you will learn how to make an animation clip and apply a simple animation through a state machine animation state machine unity’s animation state machines provide a way to see the overview all of the animation clips related to a particular character and allow various events in the game, such as user inputs, to trigger different animations state machine transitions exist to help you simplify complex state machines this allows you to have a higher level of abstraction over the state machine logic each view in the animator window has an entry and exit node the animator window specifies the state machine transitions the entry node is used when transitioning into a state machine it will be evaluated and will branch to the destination state according to the conditions set in this way, the entry node can control which state the state machine begins in, by evaluating the state of your parameters when the state machine begins because the state machine always has a default state, there will always be a default transition branching from the entry node to the default state humanoid animations unity’s animation system also has numerous special features for handling humanoid characters which give you the ability to retarget humanoid animation from any source to your own character model, as well as adjusting muscle definitions these special features are enabled by unity’s avatar system, where humanoid characters are mapped to a common internal format one of the most powerful features of mecanim is retargeting of humanoid animations this means that with relative ease, you can apply the same set of animations to various character models retargeting is only possible for humanoid models, where an avatar has been configured because this gives a correspondence between the models’ bone structure generate animation clips animation clips are one of the core elements to unity’s animation system unity supports importing animation from external sources, and offers the ability to create animation clips from scratch within the editor using the animation window animation data collection this code lab provides a tool that works with the model before then, you need animation data it can be made directly with a professional tool like maya and 3ds max or it can be obtained for free from mixamo make the character walk get the animation data here from mixamo a select the walking animation data b click the download button c the download settings appears and the animation data can be obtained by setting the following transfer the file to unity this allows you to set the following settings in the inspector window after changing the animation type to humanoid, click the apply button it is automatically retargeted to the unity avatar system the animation controller is basically set in the model a in resources > animations > avatar > controller, double click the player controller, then you can see the animator window b the animation set by default is gangnam style it’s recommended to change this to ik idle c next, apply the animation by dragging the walking animation to the button make the transition from idle to walk a right-click the idle node b connect lines from idle node to the walk node select the connecting line for transition idle → walk a uncheck has exit time b set the parameter to bool animation parameters are variables that are defined within an animator controller that can be accessed and assigned values from scripts this is how a script can control or affect the flow of the state machine c add the condition of transition idle → walk select the connecting line for transition walk → idle repeat in the same way with previous steps however, the condition of walk should be set to false look for the button behaviour script in buttonbehaviour cs, write a script that modifies parameters based on user input add the following at the bottom of the existing code public animator anim; public float speed = 1 0f; // update is called once per frame void update { if input getkey keycode space { if anim == null { if gameobject findgameobjectwithtag "gltfcomponent" { debug log "find gltfcomponent" ; gameobject o = gameobject findgameobjectwithtag "gltfcomponent" ; gltfcomponent = o getcomponent<unitygltf gltfcomponent> ; } anim = gltfcomponent getcomponent<animator> ; } } if input getkey keycode rightarrow { gltfcomponent transform rotation = quaternion euler 0, 90, 0 ; gltfcomponent transform position += gltfcomponent transform forward * time deltatime * speed; anim setbool "walk", true ; } else if input getkey keycode leftarrow { gltfcomponent transform rotation = quaternion euler 0, -90, 0 ; gltfcomponent transform position += gltfcomponent transform forward * time deltatime * speed; anim setbool "walk", true ; } else if input getkey keycode downarrow { gltfcomponent transform rotation = quaternion euler 0, 180, 0 ; gltfcomponent transform position += gltfcomponent transform forward * time deltatime * speed; anim setbool "walk", true ; } else if input getkey keycode uparrow { gltfcomponent transform rotation = quaternion euler 0, 0, 0 ; gltfcomponent transform position += gltfcomponent transform forward * time deltatime * speed; anim setbool "walk", true ; } else{ anim setbool "walk", false ; } } play and review the walking animation in the unity studio a press the spacebar on your keyboard and now you can operate the animation you set b try pressing the arrow keys of the keyboard, to make your ar emoji character move using the walking animation you're done! congratulations! you have successfully achieved the goal of this code lab now, you can create an ar emoji avatar and use it as a character in games or apps, all by yourself! learn more by going to galaxy ar emoji